23 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
24 #define For(i, a, b) for (int i=(a); i<(b); ++i)
25 #define D(x) cout << #x " is " << x << endl
30 void print(const vector
<int> &v
) {
31 for (int i
= 0; i
< v
.size(); ++i
) {
32 if (i
> 0) printf(" ");
41 while (e
--) ans
*= 10;
48 for (int k
= i
; k
>= 0; --k
) {
49 ans
= 10 * ans
+ num
[k
];
54 vector
<int> memo
[10][2];
56 vector
<int> f(int i
, bool m
) {
58 return vector
<int>(10, 0);
61 if (memo
[i
][m
].size() > 0) return memo
[i
][m
];
63 vector
<int> ans(10, 0);
65 int limit
= (m
? 9 : num
[i
] - 1);
66 for (int k
= 0; k
<= limit
; ++k
) {
67 vector
<int> s
= f(i
- 1, true);
69 for (int j
= 0; j
< 10; ++j
) ans
[j
] += s
[j
];
73 vector
<int> s
= f(i
- 1, false);
74 s
[num
[i
]] += assemble(i
- 1) + 1;
75 for (int j
= 0; j
< 10; ++j
) ans
[j
] += s
[j
];
81 vector
<int> f(int x
) {
83 while (x
> 0) num
.push_back(x
% 10), x
/= 10;
84 for (int i
= 0; i
<= 10; ++i
) {
85 memo
[i
][0].clear(), memo
[i
][1].clear();
87 vector
<int> ans
= f(num
.size() - 1, false);
88 ans
[0] -= (ten(num
.size()) - 1) / 9;
89 // for (int i = num.size() - 1; i >= 0; --i) {
90 // assert(ans[0] >= ten(i));
96 void bruteforce(int a
) {
97 vector
<int> ans(10, 0);
98 for (int i
= 1; i
<= a
; ++i
){
100 while (x
> 0) ans
[x
% 10]++, x
/= 10;
102 printf("Bruteforced answer for i=%d: ", a
);
107 // vector<int> a = f(1);
109 // for (int i = 1; i <= 100; ++i) {
110 // printf("i = %d: ", i);
114 while (cin
>> a
>> b
) {
115 if (a
== 0 and b
== 0) break;
116 vector
<int> ans
= f(b
);
118 vector
<int> remove
= f(a
- 1);
119 for (int i
= 0; i
< 10; ++i
) ans
[i
] -= remove
[i
];
121 //if (a - 1 > 0) { printf("f(%d) = ", a - 1); print(f(a - 1)); }
122 //printf("f(%d) = ", b); print(f(b));